package com.ykt.model;

import java.util.List;

/**
 * 
 * 商户类型shop_type表
 * 
 * @author tianjun
 *
 */
public class ShopType extends SeachModel<ShopType>{

	private static final long serialVersionUID = 1L;
	public static ShopType dao = new ShopType();
	
	/**
	 * 查出当前类别的所有商户(不区分商户)
	 * @return
	 */
	public List<Shop> getShops(){
		return Shop.dao.find("select * from shop where type =? ",get("id"));
	}

	/**
	 * 根据主商户ID，类别ID 查出所有当前类别的商品
	 * @param pid 主商户ID
	 * @param typeid 要查询的类别
	 * @return
	 */
	public List<Shop> getShops(Integer pid,Integer typeid){
		String sql="select s.* from shop_relation sr"
				+ "inner join shop s"
				+ "on sr.sid = s.id"
				+ "inner join shop_type st"
				+ "on st.id = s.type"
				+ "where sr.pid=? and s.type = ?";
		return Shop.dao.find(sql,get("id"));
	}
	
}
